using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using System.Reflection;

namespace OpenComposite.EII.Services
{
	#region EventArgs/Handler: RepositoryEventArgs/Handler
	public class RepositoryEventArgs : EventArgs
	{
		// Initialization
		public RepositoryEventArgs(Repository.IRepositoryItem repositoryItem)
		{
			_repositoryItem = repositoryItem;
		}

		// Properties
		private readonly Repository.IRepositoryItem _repositoryItem;
		public Repository.IRepositoryItem RepositoryItem
		{
			get { return _repositoryItem; }
		}
	}
	public delegate void RepositoryEventHandler(object sender, RepositoryEventArgs e);
	#endregion

	#region EventArgs/Handler: RepositoryChangingEventArgs/Handler
	public class RepositoryChangingEventArgs : CancelEventArgs
	{
		// Initialization
		public RepositoryChangingEventArgs(Repository.IRepositoryItem repositoryItem,
			MemberInfo member, object newValue)
			: this(repositoryItem, member, newValue, false)
		{
		}

		public RepositoryChangingEventArgs(Repository.IRepositoryItem repositoryItem, 
			MemberInfo member, object newValue, bool cancel)
			: base(cancel)
		{
			_repositoryItem = repositoryItem;
			_member = member;
			_newValue = newValue;
		}

		// Properties
		private readonly Repository.IRepositoryItem _repositoryItem;
		public Repository.IRepositoryItem RepositoryItem
		{
			get { return _repositoryItem; }
		}
		private readonly MemberInfo _member;
		public MemberInfo Member
		{
			get { return _member; }
		}
		private  object _newValue;
		public object NewValue
		{
			get { return _newValue; }
			set { _newValue = value; }
		}
	}
	public delegate void RepositoryChangingEventHandler(object sender, RepositoryChangingEventArgs e);
	#endregion

	#region EventArgs/Handler: RepositoryChangedEventArgs/Handler
	public class RepositoryChangedEventArgs : EventArgs
	{
		// Initialization
		public RepositoryChangedEventArgs(Repository.IRepositoryItem repositoryItem, MemberInfo member,
										  object oldValue, object newValue)
		{
			_repositoryItem = repositoryItem;
			_member = member;
			_oldValue = oldValue;
			_newValue = newValue;
		}

		// Properties
		private readonly Repository.IRepositoryItem _repositoryItem;
		public Repository.IRepositoryItem RepositoryItem
		{
			get { return _repositoryItem; }
		}
		private readonly MemberInfo _member;
		public MemberInfo Member
		{
			get { return _member; }
		}
		private readonly object _oldValue;
		public object OldValue
		{
			get { return _oldValue; }
		}
		private readonly object _newValue;
		public object NewValue
		{
			get { return _newValue; }
		}
	}
	public delegate void RepositoryChangedEventHandler(object sender, RepositoryChangedEventArgs e);
	#endregion

	#region EventArgs/Handler: RepositoryRenameEventArgs/Handler
	public class RepositoryRenameEventArgs : EventArgs
	{
		// Initialization
		public RepositoryRenameEventArgs(Repository.IRepositoryItem repositoryItem, string oldName, string newName)
		{
			_repositoryItem = repositoryItem;
			_oldName = oldName;
			_newName = newName;
		}

		// Properties
		private readonly Repository.IRepositoryItem _repositoryItem;
		public Repository.IRepositoryItem RepositoryItem
		{
			get { return _repositoryItem; }
		}
		private readonly string _oldName;
		public string OldName
		{
			get { return _oldName; }
		}
		private readonly string _newName;
		public string NewName
		{
			get { return _newName; }
		}
	}
	public delegate void RepositoryRenameEventHandler(object sender, RepositoryRenameEventArgs e);
	#endregion


}
